package com.enterprise.validate;
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.enterprise.daoImpl.AdminDaoImple;
import com.enterprise.domain.Admin;


public class ValidateUsername extends HttpServlet {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;


	public ValidateUsername(){
		super();
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html");
		AdminDaoImple adminDaoImple=new AdminDaoImple();
		boolean flag = false;
		String loginName=request.getParameter("loginName").toString();
		Admin admin=new Admin();
		
		admin.setUsername(loginName);
		admin.setPasswords(" ");
		flag = adminDaoImple.check(admin)>0?false:true;
		if(true == flag)
		{
			response.getWriter().write("true");//此值jquery可以接收到  
		}
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doGet(request, response); 
		
	}

}

